package com.synnex.mobile.servier.web.survey.form;

import com.synnex.mobile.generic.core.util.ObjectUtil;
import com.synnex.mobile.servier.core.survey.dto.AnswerItem;
import com.synnex.mobile.servier.core.survey.dto.Survey;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-8-8
 * Time: afternoon 11:16
 * To change this template use File | Settings | File Templates.
 */
public class AnswerItemForm implements Comparable<AnswerItemForm>{
//public class AnswerItem{

    private Integer id;
    private Survey question;
    private String title;
    private String seq;

    private Date entryDate;
    private Date updateDate;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Survey getQuestion() {
        return question;
    }

    public void setQuestion(Survey question) {
        this.question = question;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSeq() {
        return seq;
    }

    public void setSeq(String seq) {
        this.seq = seq;
    }

    public Date getEntryDate() {
        return entryDate;
    }

    public void setEntryDate(Date entryDate) {
        this.entryDate = entryDate;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public int compareTo(AnswerItemForm o) {
        if(o==null||this==null || o.getSeq()==null||this.getSeq()==null ){
            return 0;
        }             else{
                   return     this.getSeq().compareTo(o.getSeq());
        }
    }

    public static AnswerItemForm createInstance(AnswerItem questionnaire){

        if(questionnaire!=null){
            return ObjectUtil.copyProperties(questionnaire, AnswerItemForm.class);
        }else{
            return new AnswerItemForm();
        }
    }

    public static List<AnswerItemForm> createInstance(List<AnswerItem> datas){

        List<AnswerItemForm> questionnaireBos = new ArrayList<AnswerItemForm>();
        if (datas != null) {
            for (AnswerItem data : datas) {
                questionnaireBos.add(createInstance(data));
            }
        }
        return questionnaireBos;
    }
}
